package com.objectproject.main.service.subsystem.builder;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.objectproject.main.dao.MyGroupDAOImpl;
import com.objectproject.main.model.MyGroup;
import com.objectproject.main.model.MyObject;
import com.objectproject.main.model.MyProperty;
import com.objectproject.main.service.subsystem.policy.PolicyAndConfigurationRepository;


public class MyObjectBuilder {
	

	private MyGroup inheritanceAuth = new MyGroup();
	private MyGroup modificationAuth = new MyGroup();
	private boolean isAnonymous = false;//optional
	private boolean isInterface = false;//optional
	private boolean isFinal = false;
	
	private ArrayList<MyProperty> myProperties = new ArrayList<MyProperty>();//optional
	
	public MyObjectBuilder(boolean isFinal){
		this.inheritanceAuth.setGroupId(PolicyAndConfigurationRepository.ROOT_GROUP_ID);
		this.modificationAuth.setGroupId(PolicyAndConfigurationRepository.ROOT_GROUP_ID);
		this.isFinal = isFinal;
		
	}
	
	public MyObjectBuilder isAnonymous(boolean isAnonymous){
		this.isAnonymous = isAnonymous;
		return this;
	}
	
	public MyObjectBuilder isInterface(boolean isInterface){
		this.isInterface = isInterface;
		return this;
	}
	
	public MyObjectBuilder inheritanceAuth(MyGroup myGroup){
		this.inheritanceAuth = myGroup;
		return this;
	}
	
	public MyObjectBuilder modificationAuth(MyGroup myGroup){
		this.inheritanceAuth = myGroup;
		return this;
	}
	
	public MyObjectBuilder myProperties(ArrayList<MyProperty> myProperties){
		this.myProperties = myProperties;
		return this;
	}
	
	public MyObject build(){
		MyObject myObject = new MyObject();
		myObject.setInheritanceAuth(inheritanceAuth);
		myObject.setModificationAuth(modificationAuth);
		myObject.setAnonymous(isAnonymous);
		myObject.setInterface(isInterface);
		myObject.setFinal(isFinal);
		myObject.setMyProperties(myProperties);
		return myObject;
	}
}
